'use strict'
let
    http = require('http'),
    fs = require('fs'),
    url = require('url'),
    path = require('path');

let currentPath = path.resolve('.');

let server = http.createServer((req,res)=>{
    if(req.url!='/favicon.ico'){
    let filePath = path.join(currentPath, req.url);
    let file = fs.readdirSync(filePath);
    file.forEach((ele)=>{
        if(ele==='index.html'||ele==='default.html'){
             let fullPath=path.join(filePath,ele);
                fs.readFile(fullPath,(err,data)=>{
                    if(!err){
                        res.end(data)
                    }else{
                        console.log('404');
                    }
                })
        }
    })
}
})
let poat=9000;
server.listen(poat);
console.log(`服务器运行中${poat}`);